package com.sfhk.web;

import com.sfhk.domain.User;
import com.sfhk.service.UserService;
import com.sfhk.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/ShowUserServlet")
public class ShowUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        String _id = request.getParameter("id");
        int id = Integer.parseInt(_id);

        UserService userService = new UserServiceImpl();
        User user = userService.showUserById(id);

        request.setAttribute("user",user);
        request.getRequestDispatcher("/update.jsp").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
